home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Connections.h < prev    next >
Text File  |  1995-07-06  |  13KB  |  367 lines

  1. /*
  2.      File:        Connections.h
  3.  
  4.      Contains:    Communications Toolbox Connection Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CONNECTIONS__
  21. #define __CONNECTIONS__
  22.  
  23.  
  24. #ifndef __WINDOWS__
  25. #include <Windows.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <Memory.h>                                            */
  30. /*        #include <MixedMode.h>                                    */
  31. /*    #include <Quickdraw.h>                                        */
  32. /*        #include <QuickdrawText.h>                                */
  33. /*    #include <Events.h>                                            */
  34. /*        #include <OSUtils.h>                                    */
  35. /*    #include <Controls.h>                                        */
  36. /*        #include <Menus.h>                                        */
  37.  
  38. #ifndef __DIALOGS__
  39. #include <Dialogs.h>
  40. #endif
  41. /*    #include <Errors.h>                                            */
  42. /*    #include <TextEdit.h>                                        */
  43.  
  44. #ifndef __CTBUTILITIES__
  45. #include <CTBUtilities.h>
  46. #endif
  47. /*    #include <StandardFile.h>                                    */
  48. /*        #include <Files.h>                                        */
  49. /*            #include <Finder.h>                                    */
  50. /*    #include <AppleTalk.h>                                        */
  51.  
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55.  
  56. #if PRAGMA_ALIGN_SUPPORTED
  57. #pragma options align=mac68k
  58. #endif
  59.  
  60. #if PRAGMA_IMPORT_SUPPORTED
  61. #pragma import on
  62. #endif
  63.  
  64.  
  65. enum {
  66. /*    current Connection Manager version    */
  67.     curCMVersion                = 2,
  68. /*    current Connection Manager Environment Record version     */
  69.     curConnEnvRecVers            = 0,
  70. /* CMErr */
  71.     cmGenericError                = -1,
  72.     cmNoErr                        = 0,
  73.     cmRejected                    = 1,
  74.     cmFailed                    = 2,
  75.     cmTimeOut                    = 3,
  76.     cmNotOpen                    = 4,
  77.     cmNotClosed                    = 5,
  78.     cmNoRequestPending            = 6,
  79.     cmNotSupported                = 7,
  80.     cmNoTools                    = 8,
  81.     cmUserCancel                = 9,
  82.     cmUnknownError                = 11
  83. };
  84.  
  85. typedef OSErr CMErr;
  86.  
  87.  
  88. enum {
  89.     cmData                        = 1L << 0,
  90.     cmCntl                        = 1L << 1,
  91.     cmAttn                        = 1L << 2,
  92.     cmDataNoTimeout                = 1L << 4,
  93.     cmCntlNoTimeout                = 1L << 5,
  94.     cmAttnNoTimeout                = 1L << 6,
  95.     cmDataClean                    = 1L << 8,
  96.     cmCntlClean                    = 1L << 9,
  97.     cmAttnClean                    = 1L << 10,
  98. /*        Only for CMRecFlags (not CMChannel) in the rest of this enum    */
  99.     cmNoMenus                    = 1L << 16,
  100.     cmQuiet                        = 1L << 17,
  101.     cmConfigChanged                = 1L << 18
  102. };
  103.  
  104. /* CMRecFlags and CMChannel        */
  105. /*        Low word of CMRecFlags is same as CMChannel    */
  106. typedef long CMRecFlags;
  107.  
  108. typedef short CMChannel;
  109.  
  110.  
  111. enum {
  112.     cmStatusOpening                = 1L << 0,
  113.     cmStatusOpen                = 1L << 1,
  114.     cmStatusClosing                = 1L << 2,
  115.     cmStatusDataAvail            = 1L << 3,
  116.     cmStatusCntlAvail            = 1L << 4,
  117.     cmStatusAttnAvail            = 1L << 5,
  118.     cmStatusDRPend                = 1L << 6,                        /* data read pending    */
  119.     cmStatusDWPend                = 1L << 7,                        /* data write pending    */
  120.     cmStatusCRPend                = 1L << 8,                        /* cntl read pending    */
  121.     cmStatusCWPend                = 1L << 9,                        /* cntl write pending    */
  122.     cmStatusARPend                = 1L << 10,                        /* attn read pending    */
  123.     cmStatusAWPend                = 1L << 11,                        /* attn write pending    */
  124.     cmStatusBreakPend            = 1L << 12,
  125.     cmStatusListenPend            = 1L << 13,
  126.     cmStatusIncomingCallPresent    = 1L << 14,
  127.     cmStatusReserved0            = 1L << 15
  128. };
  129.  
  130. typedef unsigned long CMStatFlags;
  131.  
  132.  
  133. enum {
  134.     cmDataIn,
  135.     cmDataOut,
  136.     cmCntlIn,
  137.     cmCntlOut,
  138.     cmAttnIn,
  139.     cmAttnOut,
  140.     cmRsrvIn,
  141.     cmRsrvOut
  142. };
  143.  
  144. typedef unsigned short CMBufFields;
  145.  
  146. typedef Ptr CMBuffers[8];
  147.  
  148. typedef long CMBufferSizes[8];
  149.  
  150. typedef const long *ConstCMBufferSizesParam;
  151.  
  152.  
  153. enum {
  154.     cmSearchSevenBit            = 1L << 0
  155. };
  156.  
  157. typedef unsigned short CMSearchFlags;
  158.  
  159.  
  160. enum {
  161.     cmFlagsEOM                    = 1L << 0
  162. };
  163.  
  164. typedef unsigned short CMFlags;
  165.  
  166. struct ConnEnvironRec {
  167.     short                            version;
  168.     long                            baudRate;
  169.     short                            dataBits;
  170.     CMChannel                        channels;
  171.     Boolean                            swFlowControl;
  172.     Boolean                            hwFlowControl;
  173.     CMFlags                            flags;
  174. };
  175. typedef struct ConnEnvironRec ConnEnvironRec;
  176.  
  177. typedef ConnEnvironRec *ConnEnvironRecPtr;
  178.  
  179. typedef struct ConnRecord ConnRecord, *ConnPtr, **ConnHandle;
  180.  
  181. typedef pascal long (*ConnectionToolDefProcPtr)(ConnHandle hConn, short msg, long p1, long p2, long p3);
  182. typedef pascal void (*ConnectionSearchCallBackProcPtr)(ConnHandle hConn, Ptr matchPtr, long refNum);
  183. typedef pascal void (*ConnectionCompletionProcPtr)(ConnHandle hConn);
  184. typedef pascal void (*ConnectionChooseIdleProcPtr)(void);
  185.  
  186. #if GENERATINGCFM
  187. typedef UniversalProcPtr ConnectionToolDefUPP;
  188. typedef UniversalProcPtr ConnectionSearchCallBackUPP;
  189. typedef UniversalProcPtr ConnectionCompletionUPP;
  190. typedef UniversalProcPtr ConnectionChooseIdleUPP;
  191. #else
  192. typedef ConnectionToolDefProcPtr ConnectionToolDefUPP;
  193. typedef ConnectionSearchCallBackProcPtr ConnectionSearchCallBackUPP;
  194. typedef ConnectionCompletionProcPtr ConnectionCompletionUPP;
  195. typedef ConnectionChooseIdleProcPtr ConnectionChooseIdleUPP;
  196. #endif
  197.  
  198. struct ConnRecord {
  199.     short                            procID;
  200.     CMRecFlags                        flags;
  201.     CMErr                            errCode;
  202.     long                            refCon;
  203.     long                            userData;
  204.     ConnectionToolDefUPP            defProc;
  205.     Ptr                                config;
  206.     Ptr                                oldConfig;
  207.     long                            asyncEOM;
  208.     long                            reserved1;
  209.     long                            reserved2;
  210.     Ptr                                cmPrivate;
  211.     CMBuffers                        bufferArray;
  212.     CMBufferSizes                    bufSizes;
  213.     long                            mluField;
  214.     CMBufferSizes                    asyncCount;
  215. };
  216.  
  217. enum {
  218. /* CMIOPB constants and structure */
  219.     cmIOPBQType                    = 10,
  220.     cmIOPBversion                = 0
  221. };
  222.  
  223. struct CMIOPB {
  224.     QElemPtr                        qLink;
  225.     short                            qType;                        /* cmIOPBQType */
  226.     ConnHandle                        hConn;
  227.     Ptr                                theBuffer;
  228.     long                            count;
  229.     CMFlags                            flags;
  230.     ConnectionCompletionUPP            userCompletion;
  231.     long                            timeout;
  232.     CMErr                            errCode;
  233.     CMChannel                        channel;
  234.     long                            asyncEOM;
  235.     long                            reserved1;
  236.     short                            reserved2;
  237.     short                            version;                    /* cmIOPBversion */
  238.     long                            refCon;                        /* for application */
  239.     long                            toolData1;                    /* for tool */
  240.     long                            toolData2;                    /* for tool */
  241. };
  242. typedef struct CMIOPB CMIOPB;
  243.  
  244. typedef CMIOPB *CMIOPBPtr;
  245.  
  246. enum {
  247.     uppConnectionToolDefProcInfo = kPascalStackBased
  248.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  249.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle)))
  250.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  251.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  252.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  253.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  254.     uppConnectionSearchCallBackProcInfo = kPascalStackBased
  255.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle)))
  256.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  257.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))),
  258.     uppConnectionCompletionProcInfo = kPascalStackBased
  259.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle))),
  260.     uppConnectionChooseIdleProcInfo = kPascalStackBased
  261. };
  262.  
  263. #if GENERATINGCFM
  264. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3)        \
  265.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionToolDefProcInfo, (hConn), (msg), (p1), (p2), (p3))
  266. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum)        \
  267.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, (hConn), (matchPtr), (refNum))
  268. #define CallConnectionCompletionProc(userRoutine, hConn)        \
  269.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionCompletionProcInfo, (hConn))
  270. #define CallConnectionChooseIdleProc(userRoutine)        \
  271.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo)
  272. #else
  273. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3)        \
  274.         (*(userRoutine))((hConn), (msg), (p1), (p2), (p3))
  275. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum)        \
  276.         (*(userRoutine))((hConn), (matchPtr), (refNum))
  277. #define CallConnectionCompletionProc(userRoutine, hConn)        \
  278.         (*(userRoutine))((hConn))
  279. #define CallConnectionChooseIdleProc(userRoutine)        \
  280.         (*(userRoutine))()
  281. #endif
  282.  
  283. #if GENERATINGCFM
  284. #define NewConnectionToolDefProc(userRoutine)        \
  285.         (ConnectionToolDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionToolDefProcInfo, GetCurrentArchitecture())
  286. #define NewConnectionSearchCallBackProc(userRoutine)        \
  287.         (ConnectionSearchCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, GetCurrentArchitecture())
  288. #define NewConnectionCompletionProc(userRoutine)        \
  289.         (ConnectionCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionCompletionProcInfo, GetCurrentArchitecture())
  290. #define NewConnectionChooseIdleProc(userRoutine)        \
  291.         (ConnectionChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo, GetCurrentArchitecture())
  292. #else
  293. #define NewConnectionToolDefProc(userRoutine)        \
  294.         ((ConnectionToolDefUPP) (userRoutine))
  295. #define NewConnectionSearchCallBackProc(userRoutine)        \
  296.         ((ConnectionSearchCallBackUPP) (userRoutine))
  297. #define NewConnectionCompletionProc(userRoutine)        \
  298.         ((ConnectionCompletionUPP) (userRoutine))
  299. #define NewConnectionChooseIdleProc(userRoutine)        \
  300.         ((ConnectionChooseIdleUPP) (userRoutine))
  301. #endif
  302.  
  303. extern pascal CMErr InitCM(void);
  304. extern pascal Handle CMGetVersion(ConnHandle hConn);
  305. extern pascal short CMGetCMVersion(void);
  306. extern pascal ConnHandle CMNew(short procID, CMRecFlags flags, ConstCMBufferSizesParam desiredSizes, long refCon, long userData);
  307. extern pascal void CMDispose(ConnHandle hConn);
  308. extern pascal CMErr CMListen(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout);
  309. extern pascal CMErr CMAccept(ConnHandle hConn, Boolean accept);
  310. extern pascal CMErr CMOpen(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout);
  311. extern pascal CMErr CMClose(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout, Boolean now);
  312. extern pascal CMErr CMAbort(ConnHandle hConn);
  313. extern pascal CMErr CMStatus(ConnHandle hConn, CMBufferSizes sizes, CMStatFlags *flags);
  314. extern pascal void CMIdle(ConnHandle hConn);
  315. extern pascal void CMReset(ConnHandle hConn);
  316. extern pascal void CMBreak(ConnHandle hConn, long duration, Boolean async, ConnectionCompletionUPP completor);
  317. extern pascal CMErr CMRead(ConnHandle hConn, void *theBuffer, long *toRead, CMChannel theChannel, Boolean async, ConnectionCompletionUPP completor, long timeout, CMFlags *flags);
  318. extern pascal CMErr CMWrite(ConnHandle hConn, const void *theBuffer, long *toWrite, CMChannel theChannel, Boolean async, ConnectionCompletionUPP completor, long timeout, CMFlags flags);
  319. extern pascal CMErr CMIOKill(ConnHandle hConn, short which);
  320. extern pascal void CMActivate(ConnHandle hConn, Boolean activate);
  321. extern pascal void CMResume(ConnHandle hConn, Boolean resume);
  322. extern pascal Boolean CMMenu(ConnHandle hConn, short menuID, short item);
  323. extern pascal Boolean CMValidate(ConnHandle hConn);
  324. extern pascal void CMDefault(Ptr *theConfig, short procID, Boolean allocate);
  325. extern pascal Handle CMSetupPreflight(short procID, long *magicCookie);
  326. extern pascal Boolean CMSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  327. extern pascal void CMSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  328. extern pascal void CMSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  329. extern pascal void CMSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  330. extern pascal void CMSetupPostflight(short procID);
  331. extern pascal Ptr CMGetConfig(ConnHandle hConn);
  332. extern pascal short CMSetConfig(ConnHandle hConn, const void *thePtr);
  333. extern pascal OSErr CMIntlToEnglish(ConnHandle hConn, const void *inputPtr, Ptr *outputPtr, short language);
  334. extern pascal OSErr CMEnglishToIntl(ConnHandle hConn, const void *inputPtr, Ptr *outputPtr, short language);
  335. extern pascal long CMAddSearch(ConnHandle hConn, ConstStr255Param theString, CMSearchFlags flags, ConnectionSearchCallBackUPP callBack);
  336. extern pascal void CMRemoveSearch(ConnHandle hConn, long refnum);
  337. extern pascal void CMClearSearch(ConnHandle hConn);
  338. extern pascal CMErr CMGetConnEnvirons(ConnHandle hConn, ConnEnvironRec *theEnvirons);
  339. extern pascal short CMChoose(ConnHandle *hConn, Point where, ConnectionChooseIdleUPP idle);
  340. extern pascal void CMEvent(ConnHandle hConn, const EventRecord *theEvent);
  341. extern pascal void CMGetToolName(short procID, Str255 name);
  342. extern pascal short CMGetProcID(ConstStr255Param name);
  343. extern pascal void CMSetRefCon(ConnHandle hConn, long refCon);
  344. extern pascal long CMGetRefCon(ConnHandle hConn);
  345. extern pascal long CMGetUserData(ConnHandle hConn);
  346. extern pascal void CMSetUserData(ConnHandle hConn, long userData);
  347. extern pascal void CMGetErrorString(ConnHandle hConn, short id, Str255 errMsg);
  348. extern pascal CMErr CMNewIOPB(ConnHandle hConn, CMIOPBPtr *theIOPB);
  349. extern pascal CMErr CMDisposeIOPB(ConnHandle hConn, CMIOPBPtr theIOPB);
  350. extern pascal CMErr CMPBRead(ConnHandle hConn, CMIOPBPtr theIOPB, Boolean async);
  351. extern pascal CMErr CMPBWrite(ConnHandle hConn, CMIOPBPtr theIOPB, Boolean async);
  352. extern pascal CMErr CMPBIOKill(ConnHandle hConn, CMIOPBPtr theIOPB);
  353.  
  354. #if PRAGMA_IMPORT_SUPPORTED
  355. #pragma import off
  356. #endif
  357.  
  358. #if PRAGMA_ALIGN_SUPPORTED
  359. #pragma options align=reset
  360. #endif
  361.  
  362. #ifdef __cplusplus
  363. }
  364. #endif
  365.  
  366. #endif /* __CONNECTIONS__ */
  367.